package com.lz.controller;

import com.lz.pojo.User;
import com.lz.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <pre>
 * @描述：
 * @作者：lizhao
 * @创建时间： 2024/8/20 下午5:12
 * </pre>
 **/
//使用RequiredArgsConstructor注解，自动生成构造函数，并注入userService
@RequiredArgsConstructor
@RestController
@RequestMapping
public class UserController {
    private final UserService userService;

    /**
     * 测试saveAndUpate方法
     * 如果主键实体存在，则修改
     * @return
     */
    @PostMapping("/saveAndUpate")
    public User saveAndUpate(@RequestBody User user) {
        boolean b = userService.saveOrUpdate(user);
        return b? user : null;
    }


}
